﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Configuration;
using System.Configuration;
using System.Web.Security;

public partial class Admin_Contact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Roles.IsUserInRole("Admin")))
        {
            Response.Redirect("~/Admin/login.aspx");
        }
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {

         SmtpSection cfg = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");
        string checkError=SendEmailProviders.CheckError(SendEmailProviders.RoleSendEmail.Admin,
                "EM07 Business thông báo",
                "",
                 cfg.From,
                txtEmailTo.Text,               
                txtEmailSubject.Text,
                CKEditoConent.Text).ToString();
        if (checkError == "")
        {

           string msg = SendEmailProviders.Send(SendEmailProviders.RoleSendEmail.Admin,
                "EM07 Business thông báo",
                "",
                cfg.From,
                txtEmailTo.Text,                
                txtEmailSubject.Text,
                CKEditoConent.Text,
                Server.MapPath("~/MailContactAdmin.htm")).ToString();
           NotificationMessage.InnerHtml = NotificationHelper.SetNotification(NotificationHelper.Notification.success, msg);
        }
        else
        {
            NotificationMessage.InnerHtml = NotificationHelper.SetNotification(NotificationHelper.Notification.error,checkError);
        }
    }

    protected void btnClear_Click(object sender, EventArgs e)
    {
        Refresh();
    }

    protected void Refresh()
    {
        txtEmailSubject.Text = "";        
        txtEmailTo.Text = "";
        CKEditoConent.Text = "";
        NotificationMessage.InnerHtml = "";
    }
    protected void btnClear_Click1(object sender, EventArgs e)
    {
        Refresh();
    }
}